﻿using System;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Data.OleDb;

public partial class Login : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Form["Button1"] != null)
        {
            OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("App_Data/MainDB.mdb") + ";Persist Security Info=True");
            OleDbCommand mycomm = new OleDbCommand("SELECT * FROM [Users] WHERE UserName='" + Request.Form["TextBox1"] + "' AND PWD='" + Request.Form["TextBox2"] + "'", conn);
            conn.Open();
            OleDbDataReader rs = mycomm.ExecuteReader();
            if (rs.Read())
            {
                Response.Write("登录成功！");
            }
            else
            {
                Response.Write("用户名和密码不匹配！");
            }
            rs.Close();
            conn.Close();
            Response.End();
        }
    }
}
